package com.zhao.modleclass.activity;

import android.content.Context;
import android.content.Intent;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.v7.app.AppCompatActivity;
import android.util.TypedValue;
import android.view.View;
import android.view.Window;
import android.widget.LinearLayout;

import com.zhao.modleclass.R;

import cn.sharesdk.framework.ShareSDK;
import cn.sharesdk.onekeyshare.OnekeyShare;

/**
 * Created by 张博文 on 2016/12/16.
 */

public class SettingActivity extends AppCompatActivity {
    private Context mContext=this;
    private LinearLayout mLinearLayout;

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ShareSDK.initSDK(mContext);
        setContentView(R.layout.setting);
        //设置状态栏的颜色
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            Window window = getWindow();
            //获取样式中的属性值
            TypedValue typedValue = new TypedValue();
            this.getTheme().resolveAttribute(Color.parseColor("#FF4081"), typedValue, true);
            int[] attribute = new int[]{Color.parseColor("#FF4081")};
            TypedArray array = this.obtainStyledAttributes(typedValue.resourceId, attribute);
            int color = array.getColor(0, Color.parseColor("#FF4081"));
            array.recycle();
            window.setStatusBarColor(color);
        }

    }


    public void onClick(View view){
        switch (view.getId()){
            case R.id.iv_setting_back:
                finish();
                break;
            case R.id.setting_update_info:
                Intent update=new Intent(this,SettingPerson.class);
                startActivity(update);
                break;
            case R.id.setting_feedback:
                Intent feedback=new Intent(this,SettingFeedback.class);
                startActivity(feedback);
                break;
            case R.id.setting_about:
                Intent about=new Intent(this,Setting_About.class);
                startActivity(about);
                break;
            case R.id.setting_share:
                //一键分享
                ShareSDK.initSDK(mContext);
                OnekeyShare oks = new OnekeyShare();
                //关闭sso授权
                oks.disableSSOWhenAuthorize();
                // text是分享文本，所有平台都需要这个字段
                oks.setImageUrl("http://www1.pclady.com.cn/app/mdxy/pr20160527/index.html?appShare=qq");
                //网络图片的url：所有平台
                oks.setUrl("http://sharesdk.cn");   //网友点进链接后，可以看到分享的详情
                // 启动分享GUI
                oks.show(mContext);
                break;
            case R.id.setting_out:
                finish();
                break;
        }
    }
}
